Zero-configuration networking (zeroconf) refers to a special technology that can automatically create a usable computer network based on the Internet Protocol (IP) suite when computer devices or network peripheral devices are interconnected.
The Bonjour technology is one zeroconf technology, and the Bonjour technology is implemented based on mDNS and domain name system (DNS) based service discovery (DNS-SD). Using the Bonjour technology, a user terminal in a network can automatically propagate service information of the user terminal itself and can obtain service information of another user terminal in the network, as if one user terminal is greeting another user terminal. Service information of a user terminal is information about a service-providing user terminal, includes a service type such as printing, video playing, and other services of the service-providing user terminal, and may further include information such as an identity of the service-providing user terminal. The identity of the service-providing user terminal may be an address, in a network, of the service-providing user terminal, or a service name corresponding to the service type provided by the service-providing user terminal. Using the Bonjour technology, a service, such as printing and video playing, provided by a user terminal in an IP network can still be found by another user terminal in the network even if there is no network administrator.
However, in the Bonjour technology, because a reserved multicast address is used in an mDNS, the Bonjour technology can be implemented only when all user terminals are in a same virtual local area network (VLAN). Therefore, there is a specific limitation during implementation of the Bonjour technology. To enhance applicability of the Bonjour technology, an application scope of the Bonjour technology can be extended by adding a relay and a gateway to a network. The relay is a network device used to support packet transmission between a user terminal and the gateway. The gateway is a network device that processes a packet that is forwarded by the relay and sent by the user terminal, and the gateway forwards a processing result to the user terminal using the relay. As shown in FIG. 1, each VLAN has only one relay, and one relay may be located in different VLANs. The relay in each VLAN may be connected to, in a wired or wireless manner, different user terminals that support the Bonjour technology. The relay is in a same VLAN as a user terminal that supports Bonjour; converts a received multicast packet sent by the user terminal into a unicast packet, and then sends the converted unicast packet to the gateway. Relays in multiple VLANs may be connected to a same gateway, and the relays forward, using the connected gateway, packets sent by user terminals located in different VLANs. The gateway collects and records a relay address included in a service-requesting packet that is forwarded by the relay in each VLAN and sent by a user terminal, searches for, according to the received service-requesting packet, a corresponding service-providing user terminal, and sends, according to the recorded relay address, a search result to the user terminal using the relay. When the service-requesting user terminal and the service-providing user terminal are located in different VLANs, the service-requesting user terminal learns, using the relay and the gateway, a service provided by the service-providing user terminal.
Because there are multiple VLANs in a network, and service information of a user terminal in each VLAN is sent by a gateway to a user terminal that sends a service-requesting packet, much service information needs to be transmitted in an mDNS-based network, which results in network bandwidth waste.